<extend name="Base/common"/>
<block name="left">
</block>
<block name="body">
	<div class="container">
		<div class="find_pwd">
			<div class="pwd_form">
				<p>为了您的账号安全，请先进行身份验证</p>
				<p>已绑定手机号:{$mobile}</p><br>
				<div class="check_input clearfix">
					<span>验证号码</span>
					<input type="text" name="code" id="code" value=""  class="check_num"/>
					<input type="button" value="获取验证码" id="GetCode" class="get_code"/>
				</div>
				<div class="check_input clearfix">
					<span>重置密码</span>
					<input type="password" name="password" id="password" value="" placeholder="6~14位字母与数字" class="check_num"/>
				</div>
				<div class="check_input check_input2  clearfix">
					<span>确认密码</span>
					<input type="password" name="repassword" id="repassword" value="" placeholder="请确认密码" class="check_num"/>
				</div>
				<div class="check_input msg check_input2  clearfix" style="display: none">
					
				</div>
				<div class="sub_pwd"><a href="javascript:void(0)" class="sure_pwd">确认重置</a></div>
			</div>
			
		</div>
	</div>
<block name="script">
<script type="text/javascript">	
	$('.sure_pwd').click(function(){
		var mobile={$mobile};
		var password=$('#password').val();
		var repassword=$('#repassword').val();
		var code=$('#code').val();
		var url="{:U('User/find_pwd')}";
		var reg=/^1[3|4|5|7|8]\d{9}$/;
		if(reg.exec(mobile)==null) {
             $('.msg').css('display','block');
             $('.msg').html('手机号不匹配或不为空');
             return false;
        }
        if(password==''){
            $('.msg').css('display','block');
        	$('.msg').html('密码不能为空');
            return false;
        }
        if(repassword==''){
            $('.msg').css('display','block');
        	$('.msg').html('确认密码不能为空');
            return false;
        }
        if(password!=repassword){
            $('.msg').css('display','block');
        	$('.msg').html('密码不相同');
            return false;
        }
        if(code==''){
            $('.msg').css('display','block');
        	$('.msg').html('验证码不能为空');
            return false;
        }
		$.post(url,
			{
				phone:mobile,
				password:password,
				repassword:repassword,
				code:code,
			},function(data){
          		if(data.status){
          			$('.msg').css('display','block');
          			$('.msg').html(data.msg);
          			setTimeout(link_url,2000);	
          		}else{
          			$('.msg').css('display','block');
          			$('.msg').html(data.msg);
          		}
        },'json')   
        
		
	})
	
	
	$(document).ready(function(){
		// 获取验证码
		$("#GetCode").click(function(){    
				var mobile={$mobile};
                var reg=/^1[3|4|5|7|8]\d{9}$/;
                if (reg.exec(mobile)==null) {
                  $('.msg').html('手机号不匹配或不为空');
                	return false;
                }else{
                	$('.msg').html('');
               	}
                var url="{:U('User/send_verify')}";
                $.post(url,{mobile:mobile},function(data){
                    if(data.status){
                        setInt();
                    }else{       
                        $(".msg").html(data.msg);
                    }
                },'json')                                   
                setInt();
            })
            var count=60;
            var curCount;
            var objTime;
            function setTime(){ 
                if (curCount==0) {
                    clearInterval(objTime);
                    $('#GetCode').removeAttr('disabled');
                    $('#GetCode').css('background','#cc2a1e');
                    $('#GetCode').val('重发验证码');                    
                }else{  
                    curCount--; 
                    $('#GetCode').val(curCount + "秒后重发")
                }
            }

            function setInt() {
                curCount=count;             
                $('#GetCode').attr('disabled','true');
                $('#GetCode').css('background','#b1b1b1');
                $('#GetCode').val(curCount + "秒后重发")                                                
                objTime=setInterval(setTime,1000);
            }

	})
	function link_url(){
		var url_href="{:U('Index/index')}";;
		window.location.href=url_href;		
	}
</script>
</block>

</block>